package guiClasses;

/**
 * TCSS 360 - Project
 */

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Observer;

import javax.imageio.ImageIO;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import objectClasses.Database;
import objectClasses.Entry;

/**
 *  An Attendee panel will hold objects that an attendee needs to submit an entry.
 *  
 *  @author Abraham Santini
 */

public class AttendeePanel extends GenericPanel {


	private Entry their_entry;
	private JLabel JLabel_Image = new JLabel();
	private Image their_draft;
	private JTextField Mats = new JTextField();
	private Dimension button_dimension;
	private String file_path;
	/**
	 * Public constructor that instantiates an AttendeePanel.
	 * @param the_o_er
	 */

	public AttendeePanel(final Observer the_o_er)  {
		super(the_o_er);
		Database.loadFile();
		LinkedList<Entry> entries = Database.getUserEntries(GuiMain.getUser().getUserName());
		for (int i = 1; i <=3; i++) {
			GridBagConstraints c = GBC.GBCGen(0, 0, 0, i*2-1);
			c.anchor = GridBagConstraints.LINE_START;
			my_panel.add(new JLabel("Entry" + i), c);
			if(entries != null && i <= entries.size()) {
				c = GBC.GBCGen(0, 0, 0, (i*2));
				my_panel.add(new EntryPanelSmall(the_o_er, entries.get(i-1), i-1).getPanel(), c);
			} else {
				JButton submit = new JButton("Submit Entry" + i);
				submit.addActionListener(new ActionListener() {

				@Override
				public void actionPerformed(ActionEvent arg0) {
					setChanged();
					notifyObservers(new DraftPanel(the_o_er).getPanel());
					}
				});
			my_panel.add(submit, GBC.GBCGen(0, 0, 0, (i*2)));
			}
		}
	}


		


	}

